﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerData
{
    public int ID = 1;
    /// <summary>
    /// 时间倍率
    /// </summary>
    public TimeData TimeScale { get; set; } = new TimeData(1);
    /// <summary>
    /// 子弹信息
    /// </summary>
    public BulletData BulletData { get; set; } = new BulletData();
    /// <summary>
    /// 射击信息
    /// </summary>
    public AttackDir AttackDir { get; set; } = new AttackDir() { forward = 2,back=3,left=4,rigt=5 };

    #region 护盾部分

    /// <summary>
    /// 护甲
    /// </summary>
    public BaseData Armor { get; set; } = new BaseData();

    /// <summary>
    /// 护盾
    /// </summary>
    public BaseData Shied { get; set; } = new BaseData();

    /// <summary>
    /// 护盾恢复速度
    /// <para>x秒/格</para>
    /// </summary>
    public BaseData ShiedRecTime  { get; set; } = new BaseData(3f);

    #endregion

    #region 人物
    /// <summary>
    /// 道具冷却缩减
    /// </summary>
    public BaseData PropCD { get; set; } = new BaseData();

    /// <summary>
    /// 攻击速度,一秒几次
    /// </summary>
    public BaseData AtkSpeed { get; set; } = new BaseData(10);

    /// <summary>
    /// 血量
    /// </summary>
    public BaseData MaxHp { get; set; } = new BaseData();

    /// <summary>
    /// 魔法值
    /// </summary>
    public BaseData Mp { get; set; } = new BaseData();

    /// <summary>
    /// 移动速度
    /// </summary>
    public BaseData WalkSpeed { get; set; } = new BaseData(500f);

    /// <summary>
    /// 奔跑速度
    /// </summary>
    public BaseData RunSpeed { get; set; } = new BaseData();

    /// <summary>
    /// 翻滚间隔
    /// </summary>
    public BaseData RollInterval { get; set; } = new BaseData(1f);

    /// <summary>
    /// 翻滚间隔
    /// </summary>
    public BaseData RollSpeed { get; set; } = new BaseData(50f);

    /// <summary>
    /// 受伤间隔
    /// </summary>
    public BaseData InjuredInterval { get; set; } = new BaseData(.5f);

    #endregion

    public void Plus(PlayerData data2)
    {
        BulletData += data2.BulletData;
        AttackDir += data2.AttackDir;
        Armor += data2.Armor;
        PropCD += data2.PropCD;
        Shied += data2.Shied;
        ShiedRecTime += data2.ShiedRecTime;

        AtkSpeed += data2.AtkSpeed;
        MaxHp += data2.MaxHp;
        TimeScale.Plus(data2.TimeScale);
        Mp += data2.Mp;
        RunSpeed += data2.RunSpeed;
        WalkSpeed += data2.WalkSpeed;
        RollInterval += data2.RollInterval;
        RollSpeed += data2.RollSpeed;
        InjuredInterval += data2.InjuredInterval;
    }

    public void Minus(PlayerData data2)
    {
        BulletData -= data2.BulletData;
        AttackDir -= data2.AttackDir;
        Armor -= data2.Armor;
        PropCD -= data2.PropCD;
        Shied -= data2.Shied;
        ShiedRecTime -= data2.ShiedRecTime;

        AtkSpeed -= data2.AtkSpeed;
        MaxHp -= data2.MaxHp;
        TimeScale.Minus(data2.TimeScale);
        Mp -=  data2.Mp;
        RunSpeed -= data2.RunSpeed;
        WalkSpeed -= data2.WalkSpeed;
        RollInterval -= data2.RollInterval;
        RollSpeed -= data2.RollSpeed;
        InjuredInterval -= data2.InjuredInterval;
    }
}
